/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author JUSCELINO
 */
public abstract class AbstractUseCaseController implements UseCaseController {

    private Map<String, Command> commands;

    public AbstractUseCaseController() {
        this.commands = new HashMap<String, Command>();
        this.loadCommands(this.commands);
    }

    @Override
    public Object executeCommand(String name, Object parameter) throws Exception {
        //O name é o comando que será procurado dentro do Map
        if (!this.commands.containsKey(name)) {
            throw new IllegalArgumentException("Comando Inválido");
        }
        Command command = this.commands.get(name);
        return command.execute(parameter);

    }

    protected abstract void loadCommands(Map<String, Command> commands);
}
